优化 RuntimeService.getScriptsForTab (202606)#1511
Draft
cyfung1031 wants to merge 3 commits into
Draft
Conversation
- Severity: Low
- Status: Open
- Details: `getDisabledMatcher()` calls `stackAsyncTask("runtime_disabled_matcher", ...)` with a hardcoded string key. The `stacks` map in `async_queue.ts` is module-global. In production (single SW process, one RuntimeService), this is harmless. In tests that run concurrent `describe` blocks, multiple RuntimeService instances share this queue — their tasks are serialized unnecessarily. Correctness is maintained (each task closes over its own `this`), but cross-instance queue coupling is a latent fragility and harms parallel test throughput.
- Required action: Replace the hard-coded key with a per-instance unique string (e.g. `this.instanceId` set in the constructor via `crypto.randomUUID()` or a counter, used as `runtime_disabled_matcher:${this.instanceId}`).
- Severity: Low
- Status: Open
- Details: `runtime.ts` line 1151 (the JSDoc block above `buildDisabledMatcher`): "require disabledMatcherVersion **intergrity** check." is a misspelling of "integrity".
- Required action: Fix the typo.
- Severity: Note
- Status: Open
- Details: `updateSorter()` always calls `invalidateDisabledMatcher()` internally. In the `deleteScripts` listener (runtime.ts ~line 583), the explicit `this.invalidateDisabledMatcher()` before `this.updateSorter(...)` is redundant because both calls happen synchronously before any `await`. (By contrast, in `installScript` the explicit early call is necessary because `updateSorter` is deferred until after an `await scriptDAO.get()`.) The redundancy is harmless but slightly misleading about why the pattern is used.
- Required action: None strictly required. A short inline comment distinguishing the redundant-but-defensive call from the necessary early-call pattern (as in installScript) would help readers understand intent. Acceptable to leave as-is.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist / 检查清单
Description / 描述
Fable 5 没了但我刚发现我可以在ChatGPT网页版跑我写的 skill
自动化流程让 AI 重写了
我只改了几行。跑起来好像没问题。(但 lint-fix vitest 它跑不到...)
还没人工仔细看。
先本地跑一下再算
另外我发现了 删除Script后, Popup会有残留。我跟AI说要它帮我处理了
Screenshots / 截图